//
//  ViewController3.m
//  tongxiangOASystem
//
//  Created by michael on 17/3/20.
//  Copyright © 2017年 czd. All rights reserved.
//
#import "zfyjViewController.h"
#import "ViewController3.h"
#import "OASendMessageViewController.h"
#import "OAInBoxViewController.h"
#import "BaseModel.h"

@interface ViewController3 ()
@property (nonatomic,retain)NSDictionary *dic;

@end

@implementation ViewController3

- (void)viewDidLoad {
    [super viewDidLoad];
    
     if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {
        self.automaticallyAdjustsScrollViewInsets = NO;
}
    self.view.backgroundColor = [UIColor whiteColor];
  NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName, nil];
[self.navigationController.navigationBar setTitleTextAttributes:attributes];
self.title = @"电子邮件";
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
 self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
 self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
 [self initview];
 }
 - (void)viewWillAppear:(BOOL)animated{
 if (![_type isEqualToString:@"yes"]) {
     NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSArray *  array = @[@{@"userId":userId}];;
  [HttpTools requestWithURL:KExchmain arrays:array method:KHomePqwoiunu success:^(id JSON) {
         NSArray *tempArray  = JSON[@"data"];
      _dic = [tempArray firstObject];
 _read =_dic[@"mail"];
       [self initview];

    } failure:^(NSError *error) {
        
    }];

 NSLog(@"%@",_dic);
 }
 }
- (void)initview{


UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
float width = kScreenWidth-100;
button1.frame = CGRectMake(30, 200, width/3, 200);
button3.frame = CGRectMake(50, button1.top, width, (button1.height-10)/2);
button2.frame = CGRectMake(50, button3.bottom+10, width, button3.height);
if (_dic[@"mail"]) {

 UILabel  *label= [[UILabel alloc]initWithFrame:CGRectMake(button3.width-15,0, 15, 15)];
    label.backgroundColor = [UIColor redColor];
    label.layer.cornerRadius = 7;
    label.layer.masksToBounds = YES;
    label.textAlignment = NSTextAlignmentCenter;
//    label.font = [UIFont boldSystemFontOfSize:2.0];
    label.textColor = [UIColor whiteColor];
    label.text = _read;
    [button3 addSubview:label];
    
UIFont *font = [UIFont boldSystemFontOfSize:(10)];
label.font = font;
if ([self.read integerValue] !=0) {
            label.hidden = NO;
        }else{
         label.hidden = YES;
        }
   
}
[button1 setBackgroundImage:[UIImage imageNamed:@"转发文件"] forState:UIControlStateNormal];

[button2 setBackgroundImage:[UIImage imageNamed:@"发件箱1"] forState:UIControlStateNormal];

[button3 setBackgroundImage:[UIImage imageNamed:@"收件箱1"] forState:UIControlStateNormal];


[button1 addTarget:self action:@selector(action1) forControlEvents:UIControlEventTouchUpInside];
[button2 addTarget:self action:@selector(action2) forControlEvents:UIControlEventTouchUpInside];
[button3 addTarget:self action:@selector(action3) forControlEvents:UIControlEventTouchUpInside];
//[self.view addSubview:button1];
[self.view addSubview:button2];
[self.view addSubview:button3];
}

- (void)action1{
NSLog(@"11");
zfyjViewController *vc = [[zfyjViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];


}
- (void)action2{
UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

NSLog(@"22");
OASendMessageViewController *sendvc = (OASendMessageViewController *)[storyBoard instantiateViewControllerWithIdentifier:@"send"];
        sendvc.hidesBottomBarWhenPushed = YES;

    [self.navigationController pushViewController:sendvc animated:YES];

}
- (void)action3{
UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

 OAInBoxViewController *invc = (OAInBoxViewController *) [storyBoard instantiateViewControllerWithIdentifier:@"inbox"];
    invc.hidesBottomBarWhenPushed = YES;

    [self.navigationController pushViewController:invc animated:YES];

NSLog(@"33");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
